package com.sinoatma.physignsmonitor.http

import android.text.TextUtils
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response



class HeaderInterceptor : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val builder = chain.request().newBuilder()

        addHeader(builder,"username","atma-admin")
        addHeader(builder,"password","bc796f8341b10dc9de38fe2aa3511ab0")

        val request = builder.build()
        return chain.proceed(request)
    }

    private fun addHeader(builder: Request.Builder?, key: String, value: String) {
        if (builder != null && !TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) {
            builder.addHeader(key, value)
        }
    }
}